#
# "@(#) $Id: UpperWidget.py,v 1.1.1.1 2006-07-27 03:16:08 gioshe Exp $"
#
# This work is released under the GNU GPL, version 2 or later.
#
from qt import *
from Utils.Paths import *
from Utils.Settings import *
class UpperWidget(QWidget):
	def __init__(self,container,layout):
		
		QWidget.__init__(self,container)
		self.setFixedHeight(50)
		self.setMinimumWidth(205)

		self.layout = QHBoxLayout(self)

		self.left = UpperWidgetLeft(self)
		self.layout.addWidget(self.left)
		
		self.mid=QWidget(self)
		self.layout.addWidget(self.mid)

		self.top = UpperWidgetTop(self.mid)
		self.main=QWidget(self.mid)

		self.vlayout = QVBoxLayout(self.mid)
		self.vlayout.addWidget(self.top)
		self.vlayout.addWidget(self.main)
		self.mid.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed)

		self.main.setFixedHeight(45)
		
		self.mainLayout=QHBoxLayout(self.main)
		
		self.right = UpperWidgetRight(self)
		self.layout.addWidget(self.right)


	def getLayout(self): 	
		return self.mainLayout
	def getContainer(self):	
		return self.main


class UpperWidgetLeft(QWidget):
	def __init__(self,container):
		QWidget.__init__(self,container)
		self.left = QPixmap(art("backgroundstatusleft.png"))
		self.setFixedHeight(50)
		self.setFixedWidth(20)

	def paintEvent(self,ev):
		global _left,_middle,_right,_logo
		r = self.rect()
		p = QPainter()
		p.begin(self)
		p.setPen(Qt.NoPen)
		p.drawPixmap(QPoint(0,0),self.left)
		p.end()



class UpperWidgetRight(QWidget):
	def __init__(self,container):
		QWidget.__init__(self,container)
		self.setFixedHeight(50)
		self.setFixedWidth(20)
		self.right = QPixmap(art("backgroundstatusright.png"))

	def paintEvent(self,ev):
		global _left,_middle,_right,_logo
		r = self.rect()
		p = QPainter()
		p.begin(self)
		p.setPen(Qt.NoPen)
		p.drawPixmap(QPoint(0,0),self.right)
		p.end()

class UpperWidgetTop(QWidget):
	def __init__(self,container):
		QWidget.__init__(self,container)
		self.middle = QBrush()
		self.middle.setPixmap(QPixmap(art("backgroundstatustop.png")))
		self.setFixedHeight(5)
		self.setMinimumWidth(605)
		self.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed)

	def paintEvent(self,ev):
		global _left,_middle,_right,_logo
		r = self.rect()
		p = QPainter()
		p.begin(self)
		p.setPen(Qt.NoPen)
		p.setBrush(self.middle)
		fill = QRect(0,0,r.width(),r.height())
		p.drawRect(fill)
		p.end()

